package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class RecordTimeApsect {
    @Around("execution(* com.itheima.Service.impl.DeptServiceImpl.list())")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("recordTime-记录时间");
        long start = System.currentTimeMillis();

        // 执行目标方法
        Object result = pjp.proceed();

        long end = System.currentTimeMillis();
        System.out.println("recordTime-方法执行时间："+(end-start));
        return result;
    }
}
